package com.wyx.springbootkafkaconsumerone.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author wyx
 */
@Component
public class AutoCommitListener {

  @KafkaListener(
      topics = "${kafka.topic.test-auto-commit-topic}",
      containerFactory = "autoCommitContainerFactory",
      concurrency = "1"
  )
  public void onMsg(ConsumerRecord<?, ?> record) throws Exception {
    System.out.println("Kafka消费者接受到消息 " + record.toString());
    int i = Integer.parseInt(record.value().toString());
    Thread.sleep(1000 * 3);
    if (i > 100) {
      System.out.println(1/0);
    }
  }
}
